<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"; %>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!--页面重置-->
		<link rel="stylesheet" type="text/css" href="assets/css/tag-reset.css"/>
		<!--常用工具-->
		<link rel="stylesheet" type="text/css" href="assets/css/tag-template.css" />
		<!--外联样式-->
		<link rel="stylesheet" type="text/css" href="assets/css/universal.css" />
		<link rel="stylesheet" type="text/css" href="assets/css/home.css" />
		<title></title>
	</head>

	<body>
		
		<div class="universal-container">
			<!--导航-->
			<div class="universal-navbar">
				<div class="flow-l">
					<form action="adminLogin" method="post">
						账号：<input type="text" name="account" id="" value="" placeholder="请输入账号"/>
						密码：<input type="password" name="password" id="" value="" placeholder="请输入密码"/>
						<input type="submit" value="login"/>
					</form>
				</div>
				<div class="flow-r">
					<c:if test="${admin!=null}">
					<span>当前在线</span>&nbsp;
					<a>${admin.name}</a>&nbsp;
					<a href="adminQuit">退出</a>							
					</c:if>
				</div>
			</div>
			
			<!--内容-->
			<div class="universal-context">
				<div></div>
				<div>
					<div class="news-list flow-l">
						<c:if test="${admin==null}">
						<div class="news-list-title">
							<div>
								<span>国内新闻</span>
							</div>
							<div><c:forEach var="internal" items="${internalNews}">
								<a href="javascript:void(0);" onclick="openNewsI('${internal.news_id}')">${internal.news_title}</a></c:forEach>
							</div>
						</div>
						<div class="news-list-title">
							<div>
								<span>国外新闻</span>
							</div>
							<div><c:forEach var="external" items="${externalNews}">
								<a href="javascript:void(0);" onclick="openNewsE('${external.news_id}')">${external.news_title}</a></c:forEach>
							</div>
						</div>
						</c:if>
						<!--管理员列表-->
						<c:if test="${admin!=null}">
						<div class="admin-news-list">
							<ul>
								<li><a onclick="showNews('<%=basePath%>')">新闻中心</a></li>
								<li><a>主题管理</a>
									<ul>
										<li><a onclick="addTheme()">新增主题</a></li>
										<li><a onclick="editTheme()">编辑主题</a></li>
									</ul>
								</li>
								<li><a>新闻管理</a>
									<ul>
										<li><a onclick="addNews()">新增新闻</a></li>
										<li><a onclick="editNews()">编辑新闻</a></li>
									</ul>
								</li>
							</ul>
						</div>	
						</c:if>
					</div>
					<div class="news-page flow-r">
						<div><span id="page-title">新闻中心</span><a onclick="showNews('')">返回</a></div>
						<div class="news">
							<div id="news-themes"><c:forEach var="theme" items="${themes}">
								<a href="<%=basePath%>getNewsByThemeId?themeId=${theme.theme_id}">${theme.theme_name}</a></c:forEach>
							</div>
							<div>
								<ul><c:forEach var="news" items="${newss}">
									<li id="news-${news.news_id}"><a class="single-text-omit" onclick="openNews('${news.news_id}')">${news.news_title}</a><span>${news.news_times}</span></li></c:forEach>
								</ul>
							</div>
						</div>
						<c:forEach var="news" items="${newss}">
						<div id="news-detailed-${news.news_id}" class="news-show">
							<h2>${news.news_title}</h2>
							<p>${news.news_content}</p>
							<br/><span>${news.news_times}</span>
						</div>
						</c:forEach>
						<c:forEach var="internal" items="${internalNews}">
						<div id="news-internal-detailed-${internal.news_id}" class="news-show">
							<h2>${internal.news_title}</h2>
							<p>${internal.news_content}</p>
							<br/><span>${internal.news_times}</span>
						</div>
						</c:forEach>
						<c:forEach var="external" items="${externalNews}">
						<div id="news-external-detailed-${external.news_id}" class="news-show">
							<h2>${external.news_title}</h2>
							<p>${external.news_content}</p>
							<br/><span>${external.news_times}</span>
						</div>
						</c:forEach>
						<div class="news-admin">
							<!--添加主题-->
							<div class="add-subject">
								<form action="addTheme" method="post">
									<input type="text" name="themeName" id="add-theme-input" maxlength="4" onkeyup="checkNewTheme(1,'')" placeholder="主题长度请不要超过4个字符"/>
									<span id="add-theme-msg"></span><br>
									<input id="add-theme-submit" type="submit" value="提交主题"/>
								</form>
							</div>
							<!--编辑主题-->
							<div class="edit-subject">
								<ul><c:forEach var="theme" items="${themes}">
									<li id="theme-edit-${theme.theme_id}">
										<input type="text" value="${theme.theme_name}" disabled="true" maxlength="4"/>
										<a onclick="updateTheme('theme-edit-${theme.theme_id}','${theme.theme_id}','<%=basePath%>')">修改</a>
										<a onclick="deleteTheme('${theme.theme_id}','<%=basePath%>')">删除</a>
										<span id="update-theme-msg"></span>
									</li></c:forEach>
								</ul>
							</div>
							<!--添加新闻-->
							<div class="add-news">
								<form action="addNews" method="post">
									<select name="themeId"><c:forEach var="theme" items="${themes}">
										<option value="${theme.theme_id}">${theme.theme_name}</option></c:forEach>
									</select>
									<input type="text" name="newsTitle" placeholder="请输入新闻标题，不超过30个字符" maxlength="30" onkeyup="checkNewTheme(2,'add-news')"/>
									<span></span><br>
									<textarea name="newsContent" placeholder="请输入新闻内容" maxlength="100000"></textarea><br />
									<input type="submit" value="提交新闻"/>
								</form>
							</div>
							<!--编辑新闻-->
							<div class="edit-news">
								<ul><c:forEach var="news" items="${newss}">
									<li id="news-edit-${news.news_id}">
										<input type="text" class="single-text-omit" disabled="true" maxlength="30" value="${news.news_title}" /><span>${news.news_times}</span>
										<a onclick="updateNews('news-edit-${news.news_id}','${news.news_id}','<%=basePath%>')">修改</a>
										<a onclick="deleteNews('${news.news_id}','<%=basePath%>')">删除</a>
									</li>
									<textarea>${news.news_content}</textarea></c:forEach>
								</ul>
							</div>
						</div>
						
					</div>
				</div>
			</div>
			
			<!--页脚-->
			<div id="" class="universal-footer">
				<div id="" class="universal-foo-link">
					<a href="javascript:void(0);">关于我们</a>
					<a href="javascript:void(0);">常见问题</a>
					<a href="javascript:void(0);">反馈意见</a>
					<a href="javascript:void(0);">联系我们</a>
				</div>

				<div id="" class="universal-foo-explain">
					<p>北京传习新闻发布系统 | 网络经营许可证 京ICP备1605509号-2© Copyright©2010-2018  开发者Tag  京公网安备 110108020019号</p>
				</div>
			</div>

		</div>
		<script type="text/javascript" src="assets/libs/jquery/1.12.4/jquery.js"></script>
		<script type="text/javascript" src="assets/js/home.js"></script>
	</body>
</html>